#Makefile

CC=gcc
LD=ld

TARGET=parser
OBJ= lib_parse.o list.o btree.o exception.o debug.o
LIBNAME=parse
LIBOPTIONS=-fPIC
CFLAGS=-Wall $(LIBOPTIONS) -g3
LDFLAGS=-lm -g3 -L. -l$(LIBNAME)

all: parser

parser: parser.o
	$(CC)  -o $(TARGET) $(TARGET).o $(LDFLAGS)

parser.o: libparse.so parser.c
	$(CC) $(CFLAGS) -c parser.c

libparse.so: $(OBJ)
	$(CC) -shared -Wl,-soname,lib$(LIBNAME).so -o lib$(LIBNAME).so  $(OBJ)

lib_parse.o: lib_parse.c lib_parse.h list.c list.h btree.c btree.h exception.c exception.h defines.h debug.c debug.h std_functions.h
	$(CC) $(CFLAGS) -c lib_parse.c

list.o: list.c list.h
	$(CC) $(CFLAGS) -c list.c

btree.o: btree.c btree.h
	$(CC) $(CFLAGS) -c btree.c

exception.o: exception.c exception.h
	$(CC) $(CFLAGS) -c exception.c

debug.o: debug.c debug.h
	$(CC) $(CFLAGS) -c debug.c
clean:
	rm parser *.o *.so.* *.so -rf
	
